using System;
using FwkLight.Persistence;

namespace FwkLight.Application
{
  public class ApplicationTaskTransaction : IDisposable
  {
    private readonly INHUnitOfWork _uow;

    public ApplicationTaskTransaction ( INHUnitOfWork uow )
    {
      _uow = uow;
      uow.BeginTransaction();
    }

    public void Dispose ( )
    {
      try
      {
        _uow.Commit();
      }
      catch (Exception)
      {
        try { _uow.Rollback(); }
        catch{ }

        throw;
      }
    }

  }
}